#pragma once
#include "d3dUtil.h"
#include <list>
#include <string>
using namespace std;
#include "Ai-Kun.h"
#include "Enum.h"

struct PlayerSpells
{
	int ID;
	string name;
	int damage;
	float duration;
	float frequency;
	SpellDamageType type;
	string texFilename;
	D3DXVECTOR3 center;
	IDirect3DTexture9* spellTex;
	TargetType target;
};

struct activeSpell
{
	int spellID;
	D3DXVECTOR3 pos;
	Player *player;
	PLAYERID target;
	bool alive;
	bool finalFrames;
	int currFrame;
	float timeAccum;
	int damage;
	float duration;
	float frequency;
	float dotAccum;
	bool dotDrawing;

};


class SpellManager
{
	private:
		
		PlayerSpells spells[MAXSPELLS];//16
		std::list<activeSpell> activeSpellList;
		std::list<activeSpell>::iterator activeSpellListItr;
		void loadSpells();
		int getSpellSubscript(int spellID);
	
	

	public:
		SpellManager();
		~SpellManager();
		static SpellManager* instance();
		//void castSpell();
		void addSpell(int id, Player *player);
		
		//IDirect3DTexture9& getText
		void updateSpell(float dt, Player* p[NUMPLAYERS] );
		void drawSpell(ID3DXSprite* mSprite);
		static SpellManager* spellManagerPtr;
		IDirect3DTexture9* getTexture(int id) { return spells[id].spellTex; }
		PLAYERID getTarget(int spellID, Player *p);
		
};